package com.godot.entity.persistent;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Godot {

	// type
	public static final int kTypeNormal = 0;
	
	// status
	public static final int kStatusNormal = 0;
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	
	@Persistent
	private String name;
	
	@Persistent
	private String password;
	
	@Persistent
	private Long createTime;
	
	@Persistent
	private Long lastLoginTime;
	
	@Persistent
	private Integer type;
	
	@Persistent
	private Integer status;
	
	@Persistent
	private String email;
	
	@Persistent
	private String qName;
	
	public Godot(boolean flag) {
		this.createTime = System.currentTimeMillis();
		this.type = Godot.kTypeNormal;
		this.status = Godot.kStatusNormal;
	}
	
	public Key getKey() {
		return this.key;
	}
	
	public long getCreatTime() {
		return this.createTime;
	}
	
	public void setCreateTime(long createTime) {
		this.createTime = createTime;
	}
	
	public long getLastLoginTime() {
		return this.lastLoginTime;
	}
	
	public void setLastLoginTime(long lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}
	
	public int getType() {
		return this.type;
	}
	
	public void setType(int type) {
		this.type = type;
	}
	
	public int getStatus() {
		return this.status;
	}
	
	public void setStatus(int status) {
		this.status = status;
	}
	
	public String getName() {
		return this.name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getPassword() {
		return this.password;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	
	public void login() {
		this.setLastLoginTime(System.currentTimeMillis());
	}
	
	public String getEmail() {
		return this.email;
	}
	
	public void setEmail(String email) {
		if (email == null) {
			this.email = "";
		} else {
			this.email = email;
		}
	}
	
	public void setQName(String qName) {
		this.qName = qName;
	}
	
	public String getQName() {
		return this.qName;
	}
	
}
